home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
HTBasic 9.3
/
HTBasic 9.3.iso
/
83win
/
data1.cab
/
Basic_Plus_Examples
/
COMBWDGT
< prev
next >
Wrap
Text File
|
2001-03-02
|
7KB
|
151 lines
10 ! ***********************************************
20 ! Example: COMBO Widget
30 !
40 ! This program creates a COMBO widget and allows
50 ! the user to select an item from a supplied list
60 ! or to enter text via the keyboard.
70 !
80 ! ***********************************************
90 !
100 DIM Items$(0:15)[26],Sel$[1000]
110 INTEGER I,Sel,Fg,Bg,Lb_fg,Lb_bg
120 Items$(0)=" 6 BY 12"
130 Items$(1)=" 8 BY 16"
140 Items$(2)=" 10 BY 20"
150 Items$(3)=" EDITABLE"
160 Items$(4)=" NOT EDITABLE"
170 Items$(5)=" USE DROPDOWN BUTTON"
180 Items$(6)=" NO DROPDOWN BUTTON"
190 Items$(7)=" SHOW LIST"
200 Items$(8)=" HIDE LIST"
210 Items$(9)=" SHOW SCROLLBAR"
220 Items$(10)=" HIDE SCROLLBAR"
230 Items$(11)=" SET COLORS"
240 FOR I=BASE(Items$,1)+12 TO BASE(Items$,1)+SIZE(Items$,1)-1
250 Items$(I)="item "&VAL$(I)
260 NEXT I
270 ASSIGN @Combo TO WIDGET "COMBO";SET ("ITEMS":Items$(*),"TITLE":" Example: COMBO Widget","COLUMNS":MAXLEN(Items$(0)))
280 CONTROL @Combo;SET ("X":100,"Y":50,"WIDTH":250,"BACKGROUND":1,"LIST BACKGROUND":1)
290 CONTROL @Combo;SET ("SYSTEM MENU":"Quit")
300 ON EVENT @Combo,"SELECTION" GOSUB Disp_sel
310 ON EVENT @Combo,"KEYSTROKE" GOSUB Disp_keystroke
320 ON EVENT @Combo,"RETURN" GOSUB Disp_return
330 ON EVENT @Combo,"SYSTEM MENU" GOTO Finis
340 LOOP
350 WAIT FOR EVENT
360 END LOOP
370 !
380 Disp_sel:!
390 STATUS @Combo;RETURN ("SELECTION":Sel)
400 STATUS @Combo;RETURN ("TEXT":Sel$)
410 DISP
420 DISP "selection: ";Sel;"""";Sel$;""""
430 SELECT Sel
440 CASE 0,1,2
450 CONTROL @Combo;SET ("FONT":Sel$,"COLUMNS":MAXLEN(Items$(0)))
460 CASE 3,4
470 CONTROL @Combo;SET ("EDITABLE":Sel=3)
480 CASE 5,6
490 CONTROL @Combo;SET ("DROPDOWN BUTTON":Sel=5)
500 CASE 7,8
510 CONTROL @Combo;SET ("SHOW LIST":Sel=7)
520 CASE 9,10
530 CONTROL @Combo;SET ("SCROLLBAR":Sel=9)
540 CASE 11
550 CONTROL @Combo;SET ("SENSITIVE":0)
560 STATUS @Combo;RETURN ("PEN":Fg,"BACKGROUND":Bg,"LIST PEN":Lb_fg,"LIST BACKGROUND":Lb_bg)
570 IF FNQuery_colors(Fg,Bg,Lb_fg,Lb_bg) THEN
580 CONTROL @Combo;SET ("PEN":Fg,"BACKGROUND":Bg,"LIST PEN":Lb_fg,"LIST BACKGROUND":Lb_bg)
590 END IF
600 CONTROL @Combo;SET ("SENSITIVE":1)
610 END SELECT
620 RETURN
630 !
640 Disp_keystroke:!
650 STATUS @Combo;RETURN ("TEXT":Sel$)
660 DISP
670 DISP "keystroke: """;Sel$;""""
680 RETURN
690 !
700 Disp_return:!
710 STATUS @Combo;RETURN ("TEXT":Sel$)
720 DISP
730 DISP "return: """;Sel$;""""
740 RETURN
750 Finis:!
760 ASSIGN @Combo TO *! Delete COMBO widget
770 END
780 !
790 DEF FNQuery_colors(INTEGER Fg,Bg,Lb_fg,Lb_bg)
800 INTEGER Num_pens(0:0),Max_pen,Xoffset,Nw_height,Yoffset,Demo_offset
810 GESCAPE CRT,1;Num_pens(*)
820 Max_pen=Num_pens(0)
830 Xoffset=10+17*CHRX
840 Demo_offset=Xoffset+7*CHRX
850 Yoffset=10
860 !
870 ! Edit colors
880 !
890 ASSIGN @Panel TO WIDGET "PANEL";SET ("TITLE":"Select COMBO Colors","X":10,"Y":10,"VISIBLE":0),TRANSIENT
900 ASSIGN @Fg_label TO WIDGET "LABEL";SET ("VALUE":"Edit Pen","JUSTIFICATION":"RIGHT","X":10,"Y":Yoffset,"COLUMNS":15,"BORDER":0),PARENT @Panel
910 ASSIGN @Fg TO WIDGET "NUMBER";SET ("X":Xoffset,"Y":Yoffset,"COLUMNS":4,"FORMAT":"SHORT INTEGER","MINIMUM":0,"MAXIMUM":Max_pen,"VALUE":Fg),PARENT @Panel
920 STATUS @Fg;RETURN ("HEIGHT":Nw_height)
930 ASSIGN @Edit_demo TO WIDGET "LABEL";SET ("VALUE":"Edit Colors","X":Demo_offset,"Y":Yoffset,"COLUMNS":15,"HEIGHT":2*Nw_height,"PEN":Fg,"BACKGROUND":Bg),PARENT @Panel
940 Yoffset=Yoffset+Nw_height
950 ASSIGN @Bg_label TO WIDGET "LABEL";SET ("VALUE":"Edit Background","JUSTIFICATION":"RIGHT","X":10,"Y":Yoffset,"COLUMNS":15,"BORDER":0),PARENT @Panel
960 ASSIGN @Bg TO WIDGET "NUMBER";SET ("X":Xoffset,"Y":Yoffset,"COLUMNS":4,"FORMAT":"SHORT INTEGER","MINIMUM":0,"MAXIMUM":Max_pen,"VALUE":Bg),PARENT @Panel
970 !
980 ! List colors
990 !
1000 Yoffset=Yoffset+Nw_height
1010 ASSIGN @Lb_fg_label TO WIDGET "LABEL";SET ("VALUE":"List Pen","JUSTIFICATION":"RIGHT","X":10,"Y":Yoffset,"COLUMNS":15,"BORDER":0),PARENT @Panel
1020 ASSIGN @Lb_fg TO WIDGET "NUMBER";SET ("X":Xoffset,"Y":Yoffset,"COLUMNS":4,"FORMAT":"SHORT INTEGER","MINIMUM":0,"MAXIMUM":Max_pen,"VALUE":Lb_fg),PARENT @Panel
1030 ASSIGN @List_demo TO WIDGET "LABEL";SET ("VALUE":"List Colors","X":Demo_offset,"Y":Yoffset,"COLUMNS":15,"HEIGHT":2*Nw_height,"PEN":Fg,"BACKGROUND":Lb_bg),PARENT @Panel
1040 Yoffset=Yoffset+Nw_height
1050 ASSIGN @Lb_bg_label TO WIDGET "LABEL";SET ("VALUE":"List Background","JUSTIFICATION":"RIGHT","X":10,"Y":Yoffset,"COLUMNS":15,"BORDER":0),PARENT @Panel
1060 ASSIGN @Lb_bg TO WIDGET "NUMBER";SET ("X":Xoffset,"Y":Yoffset,"COLUMNS":4,"FORMAT":"SHORT INTEGER","MINIMUM":0,"MAXIMUM":Max_pen,"VALUE":Lb_bg),PARENT @Panel
1070 Yoffset=Yoffset+Nw_height+10
1080 STATUS @List_demo;RETURN ("WIDTH":W)
1090 STATUS @Panel;RETURN ("WIDTH":Pw,"HEIGHT":Ph,"INSIDE WIDTH":Piw,"INSIDE HEIGHT":Pih)
1100 Pw=Pw-Piw
1110 Piw=Demo_offset+W+10
1120 Pw=Pw+Piw
1130 ASSIGN @Sep TO WIDGET "SEPARATOR";SET ("X":10,"Y":Yoffset,"WIDTH":Piw-20,"HEIGHT":5),PARENT @Panel
1140 Yoffset=Yoffset+10
1150 ASSIGN @Done TO WIDGET "PUSHBUTTON";SET ("X":10+5*CHRX,"Y":Yoffset,"COLUMNS":10,"LABEL":"DONE"),PARENT @Panel
1160 ASSIGN @Cancel TO WIDGET "PUSHBUTTON";SET ("X":Demo_offset,"Y":Yoffset,"COLUMNS":10,"LABEL":"CANCEL"),PARENT @Panel
1170 STATUS @Cancel;RETURN ("HEIGHT":H)
1180 Ph=Ph-Pih
1190 Pih=Yoffset+H+10
1200 Ph=Ph+Pih
1210 CONTROL @Panel;SET ("WIDTH":Pw,"HEIGHT":Ph,"VISIBLE":1)
1220 !
1230 ON EVENT @Fg,"RETURN",2 GOSUB Set_edit
1240 ON EVENT @Fg,"DONE",2 GOSUB Set_edit
1250 ON EVENT @Bg,"RETURN",2 GOSUB Set_edit
1260 ON EVENT @Bg,"DONE",2 GOSUB Set_edit
1270 ON EVENT @Lb_fg,"RETURN",2 GOSUB Set_list
1280 ON EVENT @Lb_fg,"DONE",2 GOSUB Set_list
1290 ON EVENT @Lb_bg,"DONE",2 GOSUB Set_list
1300 ON EVENT @Done,"ACTIVATED",2 GOTO Done
1310 ON EVENT @Cancel,"ACTIVATED",2 GOTO Cancel
1320 !
1330 LOOP
1340 WAIT FOR EVENT
1350 END LOOP
1360 Set_edit:!
1370 STATUS @Fg;RETURN ("VALUE":Fg)
1380 STATUS @Bg;RETURN ("VALUE":Bg)
1390 CONTROL @Edit_demo;SET ("PEN":Fg,"BACKGROUND":Bg)
1400 RETURN
1410 !
1420 Set_list:!
1430 STATUS @Lb_fg;RETURN ("VALUE":Lb_fg)
1440 STATUS @Lb_bg;RETURN ("VALUE":Lb_bg)
1450 CONTROL @List_demo;SET ("PEN":Lb_fg,"BACKGROUND":Lb_bg)
1460 RETURN
1470 !
1480 Done: RETURN 1
1490 Cancel: RETURN 0
1500 FNEND